#include "ATMOS_LogManager.h"

#include <assert.h>
#include <iostream>

#if( ATMOS_PLATFORM == ATMOS_PLATFORM_WIN32 )
#define WIN32_LEAN_AND_MEAN
#include "windows.h"
#endif

using namespace ATMOS;

LogManager *LogManager::sInstance = 0;

LogManager::LogManager( const std::string &filename )
{
	assert( !sInstance );
	sInstance = this;

	mLog.open( filename.c_str(), std::ios::out );
	if( !mLog.is_open() )
	{
		throw std::runtime_error( "unable to open log file" );
	}
}

LogManager::~LogManager()
{
}

LogManager *LogManager::getInstance()
{
	assert( sInstance );
	return sInstance;
}

void LogManager::log( const std::string &str )
{
	std::cout << str;
	if( mLog.is_open() )
		mLog << str;
}
